package model

import (
	"github.com/shopspring/decimal"
	"gorm.io/datatypes"
	"time"
)

type Order struct {
	ID                  int64           `gorm:"primaryKey;autoIncrement;column:id;comment:主键id"`
	AddDate             *time.Time      `gorm:"column:add_date;type:datetime(6);comment:添加时间"`
	Catalog             *int            `gorm:"column:catalog;comment:订单类型"`
	LastDate            *time.Time      `gorm:"column:last_date;type:datetime(6);comment:最新修改时间"`
	OrderExt            datatypes.JSON  `gorm:"column:order_ext;comment:订单扩展信息"`
	SourceClient        *int            `gorm:"column:source_client;comment:订单来源"`
	State               *int            `gorm:"column:state;comment:订单状态"`
	ActualPaymentAmount decimal.Decimal `gorm:"column:actual_payment_amount;type:decimal(19,2);comment:实际付款金额"`
	Amount              decimal.Decimal `gorm:"column:amount;type:decimal(19,2);comment:订单金额"`
	CustomerID          *int64          `gorm:"column:customer_id;comment:下单人ID"`
	DeliveryAddress     string          `gorm:"column:delivery_address;size:255;comment:收货地址"`
	DeliveryAddressID   *int64          `gorm:"column:delivery_address_id;comment:收货地址ID"`
	FinalPayment        decimal.Decimal `gorm:"column:final_payment;type:decimal(19,2);comment:尾款"`
	FirstPayment        decimal.Decimal `gorm:"column:first_payment;type:decimal(19,2);comment:首款"`
	FirstPaymentRatio   decimal.Decimal `gorm:"column:first_payment_ratio;type:decimal(19,2);comment:首款比例"`
	MerchantDiscount    decimal.Decimal `gorm:"column:merchant_discount;type:decimal(19,2);comment:商家优惠金额"`
	MerchantID          *int64          `gorm:"column:merchant_id;comment:商家ID"`
	Num                 *int            `gorm:"column:num;comment:订单数量"`
	OrderCompletionTime *time.Time      `gorm:"column:order_completion_time;type:datetime(6);comment:完成时间"`
	OrderNo             string          `gorm:"column:order_no;size:255;comment:订单编号"`
	OrderNotes          string          `gorm:"column:order_notes;size:255;comment:订单备注"`
	OrderSource         *int            `gorm:"column:order_source;comment:订单来源"`
	OrderStatus         *int            `gorm:"column:order_status;comment:订单状态"`
	OrderTime           *time.Time      `gorm:"column:order_time;type:datetime(6);comment:下单时间"`
	OrderType           *int            `gorm:"column:order_type;comment:订单类型"`
	PaymentAccount      string          `gorm:"column:payment_account;size:255;comment:支付账户"`
	PaymentAmount       decimal.Decimal `gorm:"column:payment_amount;type:decimal(19,2);comment:支付金额"`
	PaymentMethod       *int            `gorm:"column:payment_method;comment:支付方式"`
	PaymentNotes        string          `gorm:"column:payment_notes;size:255;comment:支付备注"`
	PaymentStatus       *int            `gorm:"column:payment_status;comment:支付状态"`
	PaymentTime         *time.Time      `gorm:"column:payment_time;type:datetime(6);comment:支付时间"`
	PlatformDiscount    decimal.Decimal `gorm:"column:platform_discount;type:decimal(19,2);comment:平台优惠金额"`
	PointsDeduction     decimal.Decimal `gorm:"column:points_deduction;type:decimal(19,2);comment:积分抵扣金额"`
	ProgressPayment     decimal.Decimal `gorm:"column:progress_payment;type:decimal(19,2);comment:进度款"`
	ReferrerID          *int64          `gorm:"column:referrer_id;comment:推荐人ID"`
	ShippingNo          string          `gorm:"column:shipping_no;size:255;comment:发货单号"`
	ShippingTime        *time.Time      `gorm:"column:shipping_time;type:datetime(6);comment:发货时间"`
	StoreID             *int64          `gorm:"column:store_id;comment:门店ID"`
	TotalDiscount       decimal.Decimal `gorm:"column:total_discount;type:decimal(19,2);comment:总优惠金额"`
	FreightPrice        decimal.Decimal `gorm:"column:freight_price;type:decimal(19,2);comment:运费"`
	VerificationCode    string          `gorm:"column:verification_code;size:255;comment:核验码"`
	VerificationStatus  *int            `gorm:"column:verification_status;comment:核销状态"`
	VerificationTime    *time.Time      `gorm:"column:verification_time;type:datetime(6);comment:核验时间"`
	VoucherDeduction    decimal.Decimal `gorm:"column:voucher_deduction;type:decimal(19,2);comment:红包抵扣金额"`
	CouponID            *int64          `gorm:"column:coupon_id;comment:优惠券id"`
	Day                 *int            `gorm:"column:day;comment:天按年"`
	DayOfMonth          *int            `gorm:"column:day_of_month;comment:天按月"`
	DayOfWeek           *int            `gorm:"column:day_of_week;comment:天按周"`
	FinishTime          *time.Time      `gorm:"column:finish_time;type:datetime(6);comment:完成时间"`
	Month               *int            `gorm:"column:month;comment:月份数"`
	Quarter             *int            `gorm:"column:quarter;comment:季度"`
	Remark              string          `gorm:"column:remark;size:255;comment:订单备注"`
	Week                *int            `gorm:"column:week;comment:周数"`
	Year                *int            `gorm:"column:year;comment:年"`
	ShopID              *int64          `gorm:"column:shop_id;comment:商家id"`
	ExpressCode         string          `gorm:"column:express_code;size:30;comment:快递公司编码"`
	ExpressName         string          `gorm:"column:express_name;size:50;comment:快递公司id"`
	ExpressType         *int            `gorm:"column:express_type"`
	OpenID              string          `gorm:"column:open_id;size:50;comment:微信openId"`
	PayNo               string          `gorm:"column:pay_no;size:50;comment:支付单号"`
	WaybillID           string          `gorm:"column:waybill_id;size:255;comment:运单号"`
	WaybillToken        string          `gorm:"column:waybill_token;size:255;comment:微信物流查询token"`
}

func (Order) TableName() string {
	return "bs_order"
}
